home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tools / utils / vfnt_210 / magxptch.c < prev    next >
C/C++ Source or Header  |  1995-11-25  |  2KB  |  81 lines

  1. /* Mag!X Patch - ein Patch für Mag!X 2.0
  2.    17.12.93 Harald Sommerfeldt
  3.    nach einem Patch von Wilfried Behne
  4. */
  5.  
  6. #include <tos.h>
  7. #include <string.h>
  8.  
  9. int    patch( const char *info, int fh, long offset, const char *data, const char *patch, size_t patchlen )
  10. {
  11.     char    buffer[12];
  12.  
  13.     Cconws( info );
  14.     if ( Fseek( offset, fh, 0 /* FS_SET */ ) != offset )
  15.     {
  16.         Cconws( "Fseek() hat nicht geklappt!?\r\n" );
  17.         return 0;
  18.     }
  19.     if ( Fread( fh, patchlen, buffer ) != patchlen )
  20.     {
  21.         Cconws( "Fread() hat nicht geklappt!?\r\n" );
  22.         return 0;
  23.     }
  24.     if ( !memcmp( buffer, patch, patchlen ) )
  25.     {
  26.         Cconws( "ist schon gepatcht!\r\n" );
  27.         return 0;
  28.     }
  29.     if ( memcmp( buffer, data, patchlen ) )
  30.     {
  31.         Cconws( "ist irgendwie suspekt!?\r\n" );
  32.         return 0;
  33.     }
  34.     if ( Fseek( offset, fh, 0 /* FS_SET */ ) != offset )
  35.     {
  36.         Cconws( "der 2te Fseek() hat nicht geklappt!?\r\n" );
  37.         return 0;
  38.     }
  39.     if ( Fwrite( fh, patchlen, patch ) != patchlen )
  40.     {
  41.         Cconws( "Fwrite() hat nicht geklappt!?\r\n" );
  42.         return 0;
  43.     }
  44.     Cconws( "ok\r\n" );
  45.     return 1;
  46. }
  47.  
  48. const char  data1[] = { '\x30', '\xfc', '\x00', '\x01', '\xe7', '\x48' };
  49. const char patch1[] = { '\x52', '\x58', '\x72', '\x03', '\xe3', '\x68' };
  50.  
  51. const char  data2[] = { '\x20', '\xd9', '\x30', '\x91' };
  52. const char patch2[] = { '\x51', '\xc9', '\xff', '\xf0' };
  53.  
  54. const char  data3[] = { '\x00', '\x00', '\x00', '\x07', '\x00', '\x01',
  55.                         '\x00', '\x01', '\x00', '\x01', '\x00', '\x00' };
  56. const char patch3[] = { '\x00', '\x01', '\x00', '\x00', '\x00', '\x07',
  57.                         '\x00', '\x01', '\x00', '\x01', '\x00', '\x01' };
  58.  
  59. main()
  60. {
  61.     int    fh;
  62.  
  63.     Cconws( "\033p Mag!X 2.0 Patch - 17.12.93 Harald Sommerfeldt \033q\r\n\r\n" );
  64.     fh = (int)Fopen( "MAG!X.RAM", 0 );    /* so sollte man's eigentlich nicht machen! */
  65.     if ( fh > 0 )
  66.     {
  67.         if ( Fseek( 0L, fh, 2 /* FS_END */ ) == 148491L )
  68.         {
  69.             patch( "Patch 1: ", fh, 0x1a348L, data1, patch1, sizeof( patch1 ) );
  70.             patch( "Patch 2: ", fh, 0x1a360L, data2, patch2, sizeof( patch2 ) );
  71.             patch( "Patch 3: ", fh, 0x1a3d0L, data3, patch3, sizeof( patch3 ) );
  72.         }
  73.         else Cconws( "MAG!X.RAM hat falsche Dateilänge!\r\n" );
  74.         Fclose( fh );
  75.     }
  76.     else Cconws( "MAG!X.RAM nicht gefunden!\r\n" );
  77.     Cconin();
  78.  
  79.     return 0;
  80. }
  81.